package mk.jug.academy.preconditions;

import mk.jug.academy.model.Content;
import mk.jug.academy.model.User;

import org.springframework.util.Assert;


/**
 * Class separating the concerns of checking preconditions for
 * regarding {@link Content} processes.
 * 
 * It is usually a Precondition <-> Service pair.
 *
 * @author Ice.Penov
 */
public final class ContentPreconditions {
	
	private ContentPreconditions() {;}
	
	public static void save(Content content, User user) {
		Assert.notNull(content.getTitle(), PreconditionExceptions.TITLE_IS_NULL);
		Assert.notNull(content.getBody(), PreconditionExceptions.BODY_IS_NULL);
	}
	
	public static void delete(Content content) {
		Assert.notNull(content.getId(), PreconditionExceptions.ID_IS_NULL);		
		Assert.notNull(content.getCreatorID(), PreconditionExceptions.CONTENT_CREATOR_ID_IS_NULL);
		Assert.notNull(content.getCreatorType(), PreconditionExceptions.CONTENT_CREATOR_TYPE_IS_NULL);
	}

	public static void publish(Content content) {
		Assert.notNull(content.getId(), PreconditionExceptions.ID_IS_NULL);
	}

}
